#include <bits/stdc++.h>
using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] %= 10;
        mp[a[i]]++;
    }
    for(int i = 0; i <= 9; i++) {
        if(mp[i] == 0) continue;
        mp[i]--;
        for(int j = 0; j <= 9; j++) {
            if(mp[j] == 0) continue;
            mp[j]--;
            for(int k = 0; k <= 9; k++) {
                if(mp[k] == 0) continue;
                if((i + j + k) % 10 == 3) {
                    cout << "YES" << endl;
                    return;
                }
            }
            mp[j]++;
        }
        mp[i]++;
    }
    cout << "NO" << endl;
}

signed main() {
    int t = 1;
    cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}